package com.xiaoyg.singleFactory.factory;

import com.xiaoyg.singleFactory.concreteProduct.HistogramChart;
import com.xiaoyg.singleFactory.concreteProduct.LineChart;
import com.xiaoyg.singleFactory.concreteProduct.PieChart;
import com.xiaoyg.singleFactory.product.IChart;

/**
 * @author xiaoyg
 * @Title: ChartFactory
 * @ProjectName design_pattern
 * @Description: TODO
 * @date 2019/2/1916:50
 */
public class ChartFactory {

    public static IChart getChart(String type){
        IChart chart = null;

        if (type.equalsIgnoreCase("histogram")){
            chart = new HistogramChart();
            System.out.println("初始化设置柱状图！");
        }else if (type.equalsIgnoreCase("pie")){
            chart = new PieChart();
            System.out.println("初始化设置饼状图！");
        }else if (type.equalsIgnoreCase("line")){
            chart = new LineChart();
            System.out.println("初始化设置折线图！");
        }
        return chart;
    }

}
